<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>记账簿</title>
  <!--[if lt IE 9]>
  <script src="libs/html5shiv.min.js"></script>
  <script src="libs/respond.min.js"></script>
  <![endif]-->
  <script src="libs/jquery-1.12.1.min.js"></script>
  <link href="libs/bootstrap-3.3.6/css/bootstrap.min.css" rel="stylesheet">
  <script src="libs/bootstrap-3.3.6/js/bootstrap.min.js"></script>
  <script type="text/javascript" src="libs/handlebars.min.js"></script>
  <script type="text/javascript" src="libs/getQueryString.js">
  </script>
  
<body>
<div class="container">
    <div class="row">
      <div class="page-header">
      <h1 align="center"><strong>查询</strong></h1>
      </div>
    </div>
  </div>
<div class="container">
  <div class="row">
    <div class="col-md-12">
      <ul class="nav nav-pills">
        <li class="">
        <a href="index.html">首页</a>
        </li>
        <li class="">
        <a href="moneyout.html">新加支出</a>
        </li>
          <li class="">
        <a href="moneyin.html">新加收入</a>
        </li>
         <li class="">
        <a href="query.html">查询</a>
        </li>
          <li class="">
        <a href="static.html">统计</a>
        </li>
         <li class="active">
        <a href="">详情</a>
        </li>
      </ul>
    </div>
  </div>
</div>

<div class="container">
  <div class="row">
    <div class="col-md-12">
      <hr>
    </div>
  </div>
</div>  
<div class="container">    
    <div class="col-md-12 ">
     <div class="panel panel-primary">
    <div class="panel-heading">
    <p align="center">根据您查询所得到的所有符合条件结果</p> 
    </div>
    <div id="list1">
    </div>
    </div>
  </div>
  
</div>   
    <button id="delete">删除</button>
<script id="template" type="text/x-handlebars-template">
{{#each item}}
<div class="panel panel-default col-md-3">
  <div class="panel-body">
  <dl>
  <dt>ID</dt><dd>{{id}}</dd>
  <dt>时间</dt><dd>{{date_time}}</dd>
  <dt>类型</dt><dd>{{kind}}</dd>
  <dt>地点</dt><dd>{{place}}</dd>
  <dt>消费</dt><dd>{{money_out}}</dd>
  <dt>收入</dt><dd>{{money_in}}</dd>
  <dt>备注</dt><dd>{{remark}}</dd>
  
  </dl>
  </div>
</div>
{{/each}}
</script>
<script type="text/javascript">
  $(function(){
	  var id=getQueryString('id');
	  var url = 'query1.action?id=' + id;
	  
	  $.getJSON(url, function (res) {
		  var data ={'item':res};
	       var t =Handlebars.compile($('#template').html());
	       $('#list1').html(t(data));   
 });
	  $('#delete').click(function () {
		  $.post('delete.action', {
			  id:id
		  }, function (res, status) {
			  //加IF判断是否删除
			  if("q"==res){
				  window.location.href = 'index.html'; 
			  }
			 
		  })
	  }) 
  }) 
</script>

<script type="text/javascript">
   $(function () {
    $('#query').click(function () {
      $.post('queryresult.action', {
        day_time: $('#day_time').val(),
        kind: $('#kind').val(),
        place: $('#place').val(),
        kind: $('#kind').val(),
        money_in: $('#money_in').val(),
        money_out: $('#money_out').val(),
        remark: $('#remark').val(),
         }, function (res, status) {
			var data ={'item':res};
			var t =Handlebars.compile($('#template').html());
			$('#list1').html(t(data))
        
      });
    });
  });

 </script>
</body>
</html>